package org.noootsab.gae.games.tzaar.model {
import org.noootsab.gae.games.tzaar.model.player.Player;

public class Tzaar {
    public static var loggedInPlayer:Player = null;

    public static function logIn(login:String, password:String):Boolean {
        var player:Player = checkAndRetrieve(login, password);
        if (player === null) {
            return false;
        } else {
            Tzaar.loggedInPlayer = player;
            return true;
        }
    }

    public static function setLoggedInPlayer(player:Player):void {
        Tzaar.loggedInPlayer = player;
    }

    private static function checkAndRetrieve(login:String, password:String):Player {
        if ((login === "No0ots4b" || login === "_w_h_i_t_e__p_l_a_y_e_r_" || login === "_b_l_a_c_k__p_l_a_y_e_r_") && password === "B4stoOon") {
            var player:Player = new Player();
            player.userId = login;
            player.email = login+"@example.com";
            return player;
        } else {
            throw new Error("Unimplemented Yet: check login");
        }
    }
}
}